package com.yellow.orderservice.service;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yellow.orderservice.entity.Item;
import com.yellow.orderservice.mapper.ItemMapper;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

/**
 * @author: hy
 * @create: 2024-04-10
 */
@Service
public class ItemServiceImpl extends ServiceImpl<ItemMapper, Item> implements ItemService {

    @Resource
    private ItemMapper itemMapper;
    @Override
    public Item selectByOrderId(Long orderId){
        LambdaQueryWrapper<Item> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(Item::getItemId,orderId);
        return itemMapper.selectOne(wrapper);
    }

    @Override
    public void insertItem(Item item) {
        itemMapper.insert(item);

    }

    @Override
    public Long countItems() {
        return itemMapper.selectCount(null);
    }
}
